/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/16
\**********************/
#ifndef __LUA_RICHEDIT_H__
#define __LUA_RICHEDIT_H__
#pragma once

#include "../../Core/LuaContainer.h"

namespace DuiLib {

class LuaRichEdit : public LuaContainer
{
    SDLUA_CLASS_DECLARE(LuaRichEdit);

    bool IsMultiLine();
    void SetMultiLine(bool bMultiLine);
    bool IsWantTab();
    void SetWantTab(bool bWantTab);
    bool IsWantReturn();
    void SetWantReturn(bool bWantReturn);
    bool IsWantCtrlReturn();
    void SetWantCtrlReturn(bool bWantCtrlReturn);
    bool IsRich();
    void SetRich(bool bRich);
    bool IsReadOnly();
    void SetReadOnly(bool bReadOnly);
    bool GetWordWrap();
    void SetWordWrap(bool bWordWrap);
    int GetFont();
    int SetFont(LuaState *L);
    
    void SetEnabled(bool bEnabled);
    LONG GetWinStyle();
    void SetWinStyle(LONG lStyle);
    DWORD GetTextColor();
    void SetTextColor(DWORD dwTextColor);
    int GetLimitText();
    void SetLimitText(int iChars);
    int GetTextLength(LuaState *L);
    int GetText(LuaState *L);
    int SetText(LuaState *L);
    bool GetModify();
    void SetModify(bool bModified);
    //void GetSel(CHARRANGE &cr);
    int GetSel(LuaState *L);
    //int SetSel(CHARRANGE &cr);
    int SetSel(long nStartChar, long nEndChar);
    int ReplaceSel(LuaState *L);
    int ReplaceSelW(LuaState *L);
    int GetSelText(LuaState *L);
    int SetSelAll();
    int SetSelNone();
    WORD GetSelectionType();
    int GetZoom(LuaState *L);
    bool SetZoom(int nNum, int nDen);
    bool SetZoomOff();
    bool GetAutoURLDetect();
    bool SetAutoURLDetect(bool bAutoDetect);
    DWORD GetEventMask();
    DWORD SetEventMask(DWORD dwEventMask);
    int GetTextRange(LuaState *L);
    int HideSelection(LuaState *L);
    void ScrollCaret();
    int InsertText(LuaState *L);
    int AppendText(LuaState *L);
    /*DWORD GetDefaultCharFormat(CHARFORMAT2 &cf);
    bool SetDefaultCharFormat(CHARFORMAT2 &cf);
    DWORD GetSelectionCharFormat(CHARFORMAT2 &cf);
    bool SetSelectionCharFormat(CHARFORMAT2 &cf);
    bool SetWordCharFormat(CHARFORMAT2 &cf);
    DWORD GetParaFormat(PARAFORMAT2 &pf);
    bool SetParaFormat(PARAFORMAT2 &pf);*/
    bool CanUndo();
    bool CanRedo();
    bool CanPaste();
    bool Redo();
    bool Undo();
    void Clear();
    void Copy();
    void Cut();
    void Paste();
    int GetLineCount();
    int GetLine(LuaState *L);
    int LineIndex(LuaState *L);
    int LineLength(LuaState *L);
    int LineScroll(LuaState *L);
    long LineFromChar(long nIndex);
    int PosFromChar(LuaState *L);
    int CharFromPos(LuaState *L);
    //void EmptyUndoBuffer();
    UINT SetUndoLimit(UINT nLimit);
    /*long StreamIn(int nFormat, EDITSTREAM &es);
    long StreamOut(int nFormat, EDITSTREAM &es);*/
    void SetAccumulateDBCMode(bool bDBCMode);
    bool IsAccumulateDBCMode();

    //void DoInit();
    // ע�⣺TxSendMessage��SendMessage���������ģ�TxSendMessageû��multibyte��unicode�Զ�ת���Ĺ��ܣ�
    // ��richedit2.0�ڲ�����unicodeʵ�ֵģ���multibyte�����У������Լ�����unicode��multibyte��ת��
    bool SetDropAcceptFile(bool bAccept);
    /*virtual HRESULT TxSendMessage(UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *plresult); 
    IDropTarget* GetTxDropTarget();
    virtual bool OnTxViewChanged(BOOL bUpdate);
    virtual void OnTxNotify(DWORD iNotify, void *pv);*/

    int SetScrollPos(LuaState *L);
    void LineUp();
    void LineDown();
    void PageUp();
    void PageDown();
    void HomeUp();
    void EndDown();
    void LineLeft();
    void LineRight();
    void PageLeft();
    void PageRight();
    void HomeLeft();
    void EndRight();

    int EstimateSize(LuaState *L);
    int SetPos(LuaState *L);
    int Move(LuaState *L);
    /*void DoEvent(TEventUI& event);
    void DoPaint(HDC hDC, const RECT& rcPaint);*/

    int GetNormalImage(LuaState *L);
    int SetNormalImage(LuaState *L);
    int GetHotImage(LuaState *L);
    int SetHotImage(LuaState *L);
    int GetFocusedImage(LuaState *L);
    int SetFocusedImage(LuaState *L);
    int GetDisabledImage(LuaState *L);
    int SetDisabledImage(LuaState *L);
    //void PaintStatusImage(HDC hDC);
    int GetTextPadding(LuaState *L);
    int SetTextPadding(LuaState *L);

    int SetTipValue(LuaState *L);
    int GetTipValue(LuaState *L);
    int SetTipValueColor(LuaState *L);
    DWORD GetTipValueColor();
    void SetTipValueAlign(UINT uAlign);
    UINT GetTipValueAlign();
};

}

#endif //__LUA_RICHEDIT_H__